#ifndef GPS_POINT_H
#define GPS_POINT_H

#include <QGeoCoordinate>
#include <QDateTime>
#include <QTextStream>
#include "gps_dop.h"

QTM_USE_NAMESPACE

class GPS_point : public QGeoCoordinate
{
public:
    // Build an empty point ...
    GPS_point();
    // ... from date, position, precision and speed ...
    GPS_point(const QGeoCoordinate &coord,
               const QDateTime& time,
               double speed,
               int h_precision,
               int v_precision,
               const GPS_dop&
               );
    // ... from existing QGeoCoordinate ...
    GPS_point (const QGeoCoordinate&);
    // ... from another point!
    GPS_point(const GPS_point&);

    // Clean up the point
    ~GPS_point();

    // get/set precision
    void precision(int& h, int& v) const;
    int h_precision() const;
    int v_precision() const;
    void setPrecision(int h, int v);
    // get/set timestamp
    QDateTime timestamp() const;
    void setTimestamp(const QDateTime&);
    // get/set speed
    double speed() const;
    void setSpeed(double);
    // get/set dop
    void setDop( const GPS_dop&);
    GPS_dop dop() const;
    // get/set direction
    qreal direction() const;
    void setDirection(qreal);
    // get/set magvar
    qreal magneticVariation() const;
    void setMagneticVariation(qreal);
    // Steepness
    qreal steepness() const;
    void setSteepness(qreal);

    // Check if two points do overlap (given precision)
    bool isOverlapping(const GPS_point&) const;

    void translate( double lat, double lon );

    QString serialize() const;
    static GPS_point* unserialize(QTextStream&);

private:
    // Initialize internal data
    void initialize(const QDateTime& t,
                               double s,
                               int h,
                               int v,
                               const GPS_dop& d );

private:
    QDateTime _timestamp;
    int _h_precision_mt;
    int _v_precision_mt;
    GPS_dop _dop;
    double _speed;
    qreal _direction;
    qreal _magneticVariation;
    double _steepness;
};

#endif // GPS_POINT_H
